package cn.edu.scau.cmi.xianjiehua.simpleFactory;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextArea;

public class FactoryController implements Initializable {

	@FXML
	private ChoiceBox<String> choice;

	@FXML
	private Button show;
	
	@FXML
	private TextArea console;

	ObservableList<String> items = FXCollections.observableArrayList(SimpleFactory.DIRVER_INJURED,
			SimpleFactory.CAR_DAMAGE, SimpleFactory.CASUALTIES,SimpleFactory.MULTIPLE_ACCIDENTS);

	@Override
	public void initialize(URL location, ResourceBundle resources) {
		choice.setItems(items);
	}

	public void ButtonAction(ActionEvent event) {
		String select = choice.getValue();
		console.appendText(SimpleFactory.getInstance(select).toString()+"\n");
	}

}
